<template>
  <section>
    <h2>购物车</h2>
    <p>你好：{{ $store.state.user.age }}岁的{{ userAlias.name }}</p>
    <p>学校：{{ getUserSchool }}</p>
    <p>电话：{{ getUserMobile }}</p>
  </section>
</template>
  
  <script>
import { mapState } from "vuex";

export default {
  data() {
    return {};
  },
  // 计算属性
  computed: {
    getUserSchool() {
      return this.$store.state.user.school;
    },
    ...mapState({
      getUserMobile(state) {
        return state.user.mobile;
      },
      // 相当于访问state.user
      userAlias: "user",
    }),
  },
};
</script>
  
  <style>
</style>